<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: zhanghz001
  Date: 2020/11/3
  Time: 17:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>el表达式</title>
</head>
<body>
这是一个寂寞的天
<br>
<%--没有空指针--%>
${aaa.name}
<%--没有数组越界--%>
<%
    String[] strs = {"1111", "2222", "3333"};
    request.setAttribute("strs", strs);
%>
${strs[4]}
<%--没有字符串拼接,拼接会出错的--%>
<%--${strs[1]  +strs[2]}--%>
${strs[1] }+${strs[2]}
<%----%>
<%----%>
<%----%>
<%----%>
<%--empty运算符：
它会判断：对象是否为null，字符串是否为空字符串，集合中元素是否是0个
--%>
<br>
<% String str = null;
    String str1 = "";
    List<String> slist = new ArrayList<String>();
    pageContext.setAttribute("str", str);
    pageContext.setAttribute("str1", str1);
    pageContext.setAttribute("slist", slist);
%>
${str eq null}
${str1 eq ""}
${slist.size() eq 0}
${empty str}
${empty str1}
${empty slist}
<br>
<%--三元运算符
条件?真:假
--%>
<% request.setAttribute("gender", "female"); %>
${gender eq "female"?"female":"male"}
<input type="radio" name="gender" ${gender eq "female"?"checked":""}>
<input type="radio" name="gender"  ${gender eq "female"?"":"checked"}>
<br>


<br>
${pageContext.request.getAttribute("")}
<br>

<br>
</body>
</html>
